# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.

. $STF_SUITE/include/libtest.kshlib

set -A disk_array $(find_disks $DISKS)
case "${#disk_array[*]}" in
0)
	DISK_COUNT=0
        ;;
1)
        # We need to repartition the single disk to two slices
	DISK_COUNT=1
        META_DISK0=${disk_array[0]}
        SINGLE_DISK=$META_DISK0
        META_DISK1=$META_DISK0
        ZFS_DISK2=$META_DISK0
        META_SIDE0=${SINGLE_DISK}s0
        META_SIDE1=${SINGLE_DISK}s1
        ZFS_SIDE2=${SINGLE_DISK}s3
        ;;
2)
        # We need to repartition the single disk to two slices and allocate
	# the 2nd disk to ZFS
	DISK_COUNT=2
        META_DISK0=${disk_array[0]}
        SINGLE_DISK=$META_DISK0
        META_DISK1=$META_DISK0
        ZFS_DISK2=${disk_array[1]}
        META_SIDE0=${SINGLE_DISK}s0
        META_SIDE1=${SINGLE_DISK}s1
        ZFS_SIDE2=${ZFS_DISK2}s0
        ;;
*)
	# In this case there are at least enough disks to use.
	DISK_COUNT=3
        META_DISK0=${disk_array[0]}
        META_DISK1=${disk_array[1]}
        ZFS_DISK2=${disk_array[2]}
        META_SIDE0=${META_DISK0}s0
        META_SIDE1=${META_DISK1}s0
        ZFS_SIDE2=${ZFS_DISK2}s0
        ;;
esac

export DISK_COUNT META_DISK0 META_DISK1 ZFS_DISK2
export META_SIDE0 META_SIDE1 ZFS_SIDE2 SINGLE_DISK

export TESTFILE=testfile
export FS_SIZE=500m
export META_DEVICE_ID=d99
export META_DEVICE_PATH=/dev/md/$META_DEVICE_ID
export FILE_COUNT=20
export FILE_SIZE=$(( 1024 * 1024 ))
